package Collection.List;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @description:
 * @author: cyy
 **/
public class filter {
    public static void main(String[] args) {
        List<Map<String, Object>> strings=new ArrayList<>();
        Map<String, Object> params1 = new HashMap();
        params1.put("cuu",456);
        params1.put("id",456);
        strings.add(params1);
        Map<String, Object> params2 = new HashMap();
        params2.put("cyy",789);
        params2.put("id",456);
        strings.add(params2);
        Map<String, Object> params = new HashMap();
        params.put("cyy",123);
        params.put("id",123);
        strings.add(params);


        // 排序
        System.out.println("排序前==========================:");
        strings.forEach(System.out::println);   //打印数据

        List<Map<String, Object>> list2 = strings.stream().collect(
                Collectors.collectingAndThen(
                        Collectors.toCollection(
                                () ->new TreeSet<>(Comparator.comparing(m->m.get("id").toString()))
                        ),ArrayList::new
                )
        );    //根据value字段值去重，保留第一次放入list的map值
        System.out.println("排序后==========================:");
        list2.forEach(System.out::println);   //打印数据
    }
}
